#!/bin/bash

# get-he-domains.sh
#
# Script to get a list of all HE domains from the HESA website.
#
# Syntax:
#
#    $ ./get-he-domains.sh
#
# The script produces in stdout a list of HE domains that can be saved
# to a file with the usual bash redirection
#
#    $ ./get-he-domains.sh > he-domains.txt
#
# v0.1  22 Jun 2007
#
# Author: Ramon Casero <ramon.casero@oucs.ox.ac.uk>
# Copyright © 2007 University of Oxford
#
# This file is part of mta-tracker.
#
# mta-tracker is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# mta-tracker is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with mta-tracker.  If not, see <http://www.gnu.org/licenses/>.
#
# ChangeLog
#
# * 2008-08-21 (rcasero):
#
#   ** Upgrade licence to GPL v3.
#
# * 2007-06-22 (rcasero): v0.1. First running version.
# 
#   ** Stuart pointed me to the HESA website, that has a list of all
#      HE institutions. This script automates extracting the list of
#      domains from that page.

HEWEBPAGE=http://www.hesa.ac.uk/links/he_inst_middle.htm

while read line
  do

  # remove trailing HTML stuff
  line=${line##*http://www.}
  line=${line##*http://info.}
  line=${line##*http://}
  # remove tailing HTML stuff
  line=${line%%\"*}
  line=${line%%/*}
  # now line contains only the domain of the institution
  echo $line

done < <(wget $HEWEBPAGE -qO - | grep http) # while read line
